package com.minio.common.minio.configure;


import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

/**
 * @Author wangli
 * @Date 2023/5/23 19:01
 * @Description: minio配置
 */
@Data
public class MinioConfig {

    @Value("${minio.ip:127.0.0.1}")
    private String ip;
    @Value("${minio.port:9000}")
    private Integer port;
    @Value("${minio.accessKey:}")
    private String accessKey;
    @Value("${minio.secretKey:}")
    private String secretKey;

    @Value("${minio.bucketName:}")
    private String bucketName;
    @Value("${minio.secure:false}")
    private Boolean secure;
    @Bean
    public MinioClient minioClient() {
//        String endpoint = String.format("http://%s:%s", ip, port);
        return MinioClient.builder()
                .endpoint(ip,port,secure)
                .credentials(accessKey, secretKey)
                .build();
    }
}
